package com.lyl.lawyer.util;




//@WebFilter({"/back/*"})

public class MyFilter {
/*
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("初始化");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("doFilter");
//        判断是否已经登录,服务器
        HttpServletRequest req = (HttpServletRequest) servletRequest;
        HttpServletResponse resp = (HttpServletResponse) servletResponse;
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        String loginName = req.getParameter("loginName");//前端传递一个登录名
        // 根据登录名去判断session里面是否有值
        String object = (String) req.getSession().getAttribute(loginName);
        String path = req.getServletPath();
//        if(path.startsWith("/back/")||path.startsWith("aa/"))
        if (object == null || !object.equals(loginName)) {
            JSONObject jsonObject = new JSONObject();
           jsonObject.put("result", "notLogin");

            resp.getWriter().println(jsonObject);
        } else {
            filterChain.doFilter(servletRequest, servletResponse);
        }

    }

    @Override
    public void destroy() {

    }

*/
}
